<?
include("session.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="../webkit/utils/jquery.js"></script>
<script type="text/javascript" src="../webkit/grid/import.js"></script>
<script type="text/javascript" src="../webkit/dialog/import.js"></script>
<script type="text/javascript" src="../webkit/datepicker/WdatePicker.js"></script>
<script type="text/javascript" src="./common.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/>
</head>
<body>


<table width=100% height=100% cellspacing=0 cellpadding=0>
	<tr bgcolor="#eeeeee">
	<form name=f>
	<td height=30>&nbsp;
	客户名称：<input type=text id='client_name' size=12>　
	结算周期：<input type="text" id="date_start" name="date_start" onClick="WdatePicker({readOnly:true, skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" size="9"> - <input type="text" id="date_end" name="date_end" onClick="WdatePicker({readOnly:true, skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" size="9">　
	结算状态：<select id="pay_status"><option value=''>-请选择-</option><option value='1'>未付</option><option value='2'>已付</option></select>　
	<input type="button" value="查询" onclick="search()">　
	</td>
	</tr>
	<tr>
	<td>
		<table id="flex1" style="display:none"></table>
	</td>
	</form>
	</tr>
</table>


<script type="text/javascript">
	<?if($_SESSION['user_flag'] == "admin") {?>
	var h = parent.document.body.clientHeight-(115+102);
	<?} else {?>
	var h = parent.document.body.clientHeight-(115+76);
	<?}?>
	if(h < 0) h = 'auto'
	$("#flex1").flexigrid({
		url: 'money_query.php?action=list',
		dataType: 'json',
		colModel : [
			{display: 'ID', name : 'a', width : 30, sortable : false, align: 'center'},
			{display: '客户名称', name : 'a', width : 150, sortable : false, align: 'center'},
			{display: '结算状态', name : 'pay_status', width : 60, sortable : true, align: 'center'},
			{display: '时间范围', name : 'a', width : 160, sortable : false, align: 'center'},
			{display: '签约单价', name : 'order_price', width : 60, sortable : true, align: 'center'},
			{display: '签约数量', name : 'order_count', width : 60, sortable : true, align: 'center'},
			{display: '周期收入', name : 'total_income', width : 60, sortable : true, align: 'center'},
			{display: '提成比例', name : 'calc_money_rate', width : 60, sortable : true, align: 'center'},
			{display: '提成金额', name : 'total_money', width : 60, sortable : true, align: 'center'},
            {display: '结算周期', name : 'pay_period', width : 60, sortable : false, align: 'center'},
			{display: '签约时间', name : 'order_date', width : 100, sortable : true, align: 'center'},
			{display: '用户归属', name : 'user_name', width : 80, sortable : false, align: 'center'},
			{display: '商机归属', name : 'client_source', width : 80, sortable : false, align: 'center'},
			{display: '生成时间', name : 'calc_time', width : 150, sortable : true, align: 'center'}
			],
		<?if($_SESSION['user_flag'] == "admin") {?>
		buttons : [
            {name: '确认付款', bclass: 'other', onpress : pay},
			{name: '删除', bclass: 'del', onpress : del}
		],
		<?}?>
		async : true,
		usepager: true,
		title: '结算列表',
		useRp: true,
		rp: 15,
		showTableToggleBtn: false,
		width: 'auto',
		height: h,
		resizable : false,
		singleSelect : true,
		onSuccess : function() {show_sum_total("6,8,")}	
	});

    
   
	<?
	$add_url = "money_panel.php?op=add";
	$edit_url = "money_panel.php?op=edit&id=";
	$del_url = "money_query.php?action=del&id=";
	$dlg_size = "600,320";
	require("grid_common_js.php");
	?>

	function pay() {
		var id = $("#flex1").getSelectedRowId();
		if(isNaN(id) || id<1) {
			alert("请选择一条有效记录！");
			return false;
		}
		if(confirm("确认已进行付款吗?")) {
			$.get("money_query.php?action=pay&id="+id, function(data){
				if(data == "ok") {
					alert("操作成功！");
					refreshGrid();
				} else {
					alert(data);	
				}
			});
		}
	}

	function search() { 
		var url = "money_query.php?action=list";
        if($("#pay_status").val()!="") {
            url += "&pay_status="+ $("#pay_status").val();
        }      
        if($("#date_start").val()!="") {
            url += "&date_start="+ $("#date_start").val();
        }    
        if($("#date_end").val()!="") {
            url += "&date_end="+ $("#date_end").val();
        }    
        if($("#client_name").val()!="") {
            url += "&client_name="+ encodeURI($("#client_name").val());
        }    
		$('#flex1').flexOptions({'url': url}).flexReload(); 
	}

</script>
</body>
</html>
